
function onClickShowCron(){
	var diag = new Dialog();
	diag.Width = 900;
	diag.Height = 470;
	diag.Title = "内容页为html代码的窗口";
	
	diag.URL = "./cron/cron.html";
	
	diag.OKEvent = function(){
		
		//数据解析到当前窗口
		var expression = diag.innerFrame.contentWindow.document.getElementById('cron').value;
		
		document.getElementById('expression').value = expression;
		timeCheckField($("#expression"));

		diag.close();
		
		//点击确定后调用的方法
		};
		
	diag.show();

}
	
function timeCheckField(self){
	
	var f= $(self).val();
	if(f == ""){
		$("#expressionDes").val("");
		return;
	}
	
	showExDetails(f);
	
}

function showExDetails(p){
	
	var postData = {"expression":p}; 
	
	
	$.axse(
	    "showExDes",
	    postData,
	    function(d){
	    	if(d.code == 'J000000'){
	    		document.getElementById('expressionDes').value=d.resultMap.exdes;
	    	}
	    	else{
	    		document.getElementById('expressionDes').value="解析失败";
	    	}
	    }, 
	    function(e){
	    	document.getElementById('expressionDes').value="解析失败";
	    }
	);
		
			
}

function onClickAddJob(){
	
	//获取数据 并检查数据
	var schedName = document.getElementById("schedName").value;
	var jobName = document.getElementById("jobName").value;
	var jobGroup = document.getElementById("jobGroup").value;
	var jobClassName = document.getElementById("jobClassName").value;
	var description = document.getElementById("description").value;
	var isRecovery = document.getElementById("isRecovery").value;;
	var triggerName = document.getElementById("triggerName").value;
	var triggerGroup = document.getElementById("triggerGroup").value;
	var expression = document.getElementById("expression").value;
	
	if(schedName == ""){
		alert("计划名称吧不能为空");
		return false;
	}
	if(jobName == ""){
		alert("任务名称不能为空");
		return false;
	}
	if(jobGroup == ""){
		alert("任务组名称不能为空");
		return false;
	}
	if(jobClassName == ""){
		alert("执行class名不能为空");
		return false;
	}
	if(triggerName == ""){
		alert("触发器名不能为空");
		return false;
	}
	if(triggerGroup == ""){
		alert("触发器组名不能为空");
		return false;
	}
	if(expression == ""){
		alert("触发规则不能为空");
		return false;
	}

	//形成post数据
	var postData = {"schedName":schedName,
		   					"jobName":jobName,
		   					"jobGroup":jobGroup,
		   					"jobClassName":jobClassName,
		   					"description":description,
		   					"isRecovery":isRecovery,
		   					"triggerName":triggerName,
		   					"triggerGroup":triggerGroup,
		   					"expression":expression}; 
	
	//发送数据
	 
    $.axse(
        "addNewJob",
        postData,
        function(d){
            manageSuc(d);
        }, 
        function(e){
        	messageJDialog("操作失败！网络繁忙\n\n");
        }
    );
	       
}

	function manageSuc(data){
	if(data.code == 'J000000'){
			alertJDialog('添加任务成功！', gotoIndex);
	
		}else {
			var des = data.resultMap.errDes;
			messageJDialog("添加任务失败！!!");
		} 
	}
function onHelp(){
	messageJDialog("需要添加新的调度器选项，请与管理员（付清奎）联系！");
}
	
function reset(){
	location.reload();	
}
	
function gotoIndex(){
	
	window.location.href='./index'; 
}
function toIndex(){
	self.location='index';	
}